const axios = require('axios');

const BASE_URL = 'http://localhost:3001';

async function testSkillDetail() {
  console.log('🧪 开始测试技能详情接口...\n');

  // 测试不同的技能ID
  const testIds = ['1', '2', '3', 'undefined', '999'];

  for (const id of testIds) {
    console.log(`📋 测试技能ID: ${id}`);
    
    try {
      const response = await axios.get(`${BASE_URL}/api/skills/${id}`, {
        timeout: 5000
      });

      console.log(`✅ 测试结果: 成功`);
      console.log(`📝 状态码: ${response.status}`);
      console.log(`📝 响应数据: ${response.data.success ? '成功' : '失败'}`);
      
      if (response.data.success && response.data.data) {
        console.log(`📝 技能名称: ${response.data.data.name || 'N/A'}`);
        console.log(`📝 技能类别: ${response.data.data.category || 'N/A'}`);
      } else {
        console.log(`📝 错误信息: ${response.data.message || 'N/A'}`);
      }
    } catch (error) {
      console.log(`❌ 测试结果: 失败`);
      if (error.response) {
        console.log(`📝 状态码: ${error.response.status}`);
        console.log(`📝 错误信息: ${error.response.data?.message || error.message}`);
      } else {
        console.log(`📝 错误信息: ${error.message}`);
      }
    }
    
    console.log('---');
  }

  console.log('🎉 技能详情接口测试完成！');
}

testSkillDetail().catch(console.error); 